package top.as.sean.api.controller.system;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.as.sean.biz.system.IUserRole;
import top.as.sean.common.ip2region.Ip2regionUtils;
import top.as.sean.common.response.Result;
import top.as.sean.dao.dto.system.UserRoleCancel;

import javax.annotation.PostConstruct;

/**
 * 用户-角色
 *
 * @author: ArchieSean
 * @create: 2023/2/3
 */
@Slf4j
@RestController
@RequestMapping("userRole")
@RequiredArgsConstructor
public class UserRoleController {

    private final IUserRole iUserRole;

    /**
     * 批量取消授权
     *
     * @param dto 入参
     * @return result
     */
    @PostMapping("cancel")
    public Result<?> cancel(@Validated @RequestBody UserRoleCancel dto) {
        iUserRole.cancel(dto);
        return Result.success();
    }

    /**
     * 新增授权
     * @param dto 入参
     * @return obj
     */
    @PostMapping("save")
    public Result<?> save(@Validated @RequestBody UserRoleCancel dto) {
        iUserRole.saveBatch(dto);
        return Result.success();
    }
}
